#@head() #@header()
<title>融资需求管理</title>
#@aside("custser")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active" ><a style="cursor:pointer" >工单信息</a></li>
            </ul>
            <div class="tab-content">
              <!-- 来访 -->
			  <div class="tab-pane active" id="tab_1">
				<div class="box-body">
					<table id="example1" class="table table-bordered table-striped dataTable col-md-8" role="grid" aria-describedby="example1_info">
						<tbody>
						<tr role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">工单ID：</td>
						  <td id="id" class="sorting_1"></td>
						</tr>
						<tr role="row" class="even">
						  <td align="right" style="width:130px;" class="sorting_1">客户姓名：</td>
						  <td id="real_name" class="sorting_1"></td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">客户号码：</td>
						  <td id="mobile" class="sorting_1"></td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">创建人：</td>
						  <td id="creater_real_name" class="sorting_1"></td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">所属客服：</td>
						  <td id="agent_real_name" class="sorting_1"></td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">创建时间：</td>
						  <td id="create_time" class="sorting_1"></td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">客户问题：</td>
						  <td id="matter" class="sorting_1"></td>
						</tr> 
						<tr hidden id="solvetheone" role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">解决方案：</td>
						  <td  class="sorting_1">
							<textarea style="width:80%" id="solve" class="form-control" rows="3" placeholder="请输入"></textarea>
						  </td>
						</tr>
						<tr hidden id="solvethetwo" role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">解决方案2：</td>
						  <td  class="sorting_1">
							<textarea style="width:80%" id="solvetwo" class="form-control" rows="3" placeholder="请输入"></textarea>
						  </td>
						</tr>
						<tr hidden id="solvethethree" role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">解决方案3：</td>
						  <td  class="sorting_1">
							<textarea style="width:80%" id="solvethree" class="form-control" rows="3" placeholder="请输入"></textarea>
						  </td>
						</tr>
						<tr id="issolve1" role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">是否解决：</td>
						  <td  class="sorting_1">
							<select id="isSolve5" style="width:40%" class="form-control">
								<option value="1">已解决</option>
								<option value="0">未解决</option>
							</select>
						  </td>
						</tr>
						<tr id="subbutton" role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1"></td>
						  <td  class="sorting_1">
							<button id="submit" type="button" class="btn btn-success">提交</button>
						  </td>
						</tr>
						</tbody>
					</table>		
				</div>
			</div>
		</div>
	</div>
	</section>
</div>
#@footer()
<script>
 $(document).ready(function(){
	var id = GetRequest(id).id;
	$.getJSON("/visit/info?token=#(session.token??)&id="+id, function(datainfo) {
		console.log(datainfo);
		setFormVals(datainfo.data.item);
		var item = datainfo.data.item;
		$("#isSolve").val(item.is_solve); 
		$('#solve').val(item.solve); 
		$('#solvetwo').val(item.solve2); 
		$('#solvethree').val(item.solve3);
		if(item.is_solve==1){
			$("#isSolve5").attr("disabled","disabled"); 
			$("#subbutton").remove();
			if(!$.isBlank(item.solve)){
				$('#solvetheone').show();
				$('#solve').attr("readonly","readonly");
			}
			if(!$.isBlank(item.solve2)){
				$('#solvethetwo').show(); 
				$('#solvetwo').attr("readonly","readonly");
			}
			if(!$.isBlank(item.solve3)){
				$('#solvethethree').show();
				$('#solvethree').attr("readonly","readonly");
			}
		}else{
			if(!$.isBlank(item.solve)){
				$('#solvetheone').show();
				$('#solve').attr("readonly","readonly");
				$('#solvethetwo').show(); 
				if(!$.isBlank(item.solve2)){
					console.log(item.solve2);
					$('#solvetwo').attr("readonly","readonly");
					$('#solvethethree').show();
					if(!$.isBlank(item.solve3)){
						$('#solvethree').attr("readonly","readonly");
					}
				}
			}else{
				$('#solvetheone').show();
			}
		}
	});	
	$("#submit").click(function() {
		var solve = $("#solve").val();
		var solve2 = $("#solvetwo").val();
		var solve3 = $("#solvethree").val();
		var isSolve5 = $("#isSolve5").val();
		ajax("#(path)/visit/solve?token=#(session.token??)&id="+id+"&solve="+solve+"&solve2="+solve2+"&solve3="+solve3+"&isSolve="+isSolve5,{},function(data){
			if(data.code=='success'){
				layer.msg(data.msg, {icon:1},function(){
					//location.href="#(path)/admin/page/custser-workorder";
				});
			}else if(data.code=='error'){
				layer.msg(data.msg, {icon : 2});
			}
		});
	});
	function GetRequest() {  
	   var url = location.search; //获取url中"?"符后的字串  
	   var theRequest = new Object();  
	   if (url.indexOf("?") != -1) {  
		  var str = url.substr(1);  
		  strs = str.split("&");  
		  for(var i = 0; i < strs.length; i ++) {  
			 theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
		  }  
	   }  
	   return theRequest;  
	}  
});
   
</script> 

</body>
</html>

